package com.ushio.authservice.user.controller;

import com.ushio.authservice.user.entity.qo.LoginUserQo;
import com.ushio.authservice.user.entity.vo.LoginUserVo;
import com.ushio.authservice.user.service.LoginService;
import com.ushio.commonmodule.pojo.result.Result;
import com.ushio.commonmodule.pojo.result.ResultCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 19451
 */
@RestController
@RequestMapping("login")
@Tag(name="login Api",description = "登录")
public class LoginController {

    @Autowired
    LoginService loginService;

    @PostMapping()
    @Operation(summary = "账号密码登录", description = "账号密码登录")
    public Result<LoginUserVo> getLoginUser(@RequestBody LoginUserQo loginUserQo){
        try{

            LoginUserVo loginUserVo = loginService.getLoginUser(loginUserQo);

            return Result.success(loginUserVo);

        }catch (Exception e){

            e.printStackTrace();

            return Result.fail(ResultCode.SECURITY,e.getMessage());
        }
    }

}
